/*
This work is donated to the public domain. Make of it what you will.

*/


function loadPrefs(){
	document.getElementById("version").innerText = "v"+version();
}


function version(){
    var xmlReq = new XMLHttpRequest(); 
    xmlReq.open("GET", "Info.plist", false); 
    xmlReq.send(null); 
    
    var xml = xmlReq.responseXML; 
    var keys = xml.getElementsByTagName("key");
    var ver = "0.0";

    for(i=0; i<keys.length; i++){
	if("CFBundleVersion" == keys[i].firstChild.data){
	    ver = keys[i].nextSibling.nextSibling.firstChild.data;
	    break;
	}
    }

    return ver; 
}


function showPrefs(){
    var front = document.getElementById("front");
    var back = document.getElementById("back");

    document.getElementById("flip").style.display = "none";
    document.getElementById("fliprollie").style.display = "none";
    document.getElementById("backFlip").style.display = "none";
    document.getElementById("backFliprollie").style.display = "none";
	
    if(window.widget){
	widget.prepareForTransition("ToBack");
    }

    front.style.display="none";
    back.style.display="block";

    if(window.widget){
	setTimeout("widget.performTransition();", 0);
    }

    FRONT_OR_BACK = "back";

    calculateAndShowThumb();
}


function hidePrefs(event){
    var front = document.getElementById("front");
    var back = document.getElementById("back");

    document.getElementById("flip").style.display = "none";
    document.getElementById("fliprollie").style.display = "none";
    document.getElementById("backFlip").style.display = "none";
    document.getElementById("backFliprollie").style.display = "none";

    if(window.widget){
	widget.prepareForTransition("ToFront");
    }

    back.style.display="none";
    front.style.display="block";
	
    if(window.widget){
	setTimeout("widget.performTransition();", 0);
    }

    FRONT_OR_BACK = "front";
    calculateAndShowThumb();
}


function showFlip(){
    document.getElementById("flip").style.display = "block";
    document.getElementById("backFlip").style.display = "block";
}


function hideFlip(){
    document.getElementById("flip").style.display = "none";
    document.getElementById("backFlip").style.display = "none";
}


function showCircle(){
    document.getElementById("fliprollie").style.display = "block";
}


function hideCircle(){
    document.getElementById("fliprollie").style.display = "none";
}


function showBackCircle(){
    document.getElementById("backFliprollie").style.display = "block";
}


function hideBackCircle(){
    document.getElementById("backFliprollie").style.display = "none";
}